package com.xxl.job.spring.starter;

import com.xxl.job.core.context.XxlJobHelper;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class WebConsoleLog {

    public static void info(String str, Object... args) {
        log.info(str, args);
        XxlJobHelper.log(str, args);
    }

    public static void warn(String str, Object... args) {
        log.warn(str, args);
        XxlJobHelper.log(str, args);
    }

    public static void error(String str, Object... args) {
        log.error(str, args);
        XxlJobHelper.log(str, args);
        if (args != null && args.length > 0) {
            Object arg = args[args.length - 1];
            if (arg instanceof Throwable) {
                XxlJobHelper.log((Throwable) arg);
            }
        }
        XxlJobHelper.handleFail(str);
    }
}
